﻿using System;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.Diagnostics.Logging
{
    /// <summary>
    /// Base contract for Log abstract factory
    /// </summary>
    [ContractClass(typeof(LoggerFactoryContract))]
    public interface ILoggerFactory
    {
        ILogger Create(Type type);

        ILogger Create(string name);

        bool InitializeLoggingFactory(string settingsFile, string factoryName);
    }

    [ContractClassFor(typeof(ILoggerFactory))]
    internal abstract class LoggerFactoryContract : ILoggerFactory
    {
        public ILogger Create(Type type)
        {
            Contract.Requires<ArgumentNullException>(type != null, "type could not be null.");
            return default(ILogger);
        }

        public ILogger Create(string name)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(ILogger);
        }


        public bool InitializeLoggingFactory(string settingsFile, string factoryName)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(settingsFile), "settingsFile could not be null or empty");
            return default(bool);
        }
    }
}
